# -*- coding: utf-8 -*-
"""
反汇编良性软件、恶意软件、测试软件　　　
"""

import os
import subprocess

def disassemble(frompath, topath, num, start=0):
    files = os.listdir(frompath)
    files = files[start:num]
        
    total = len(files)
    
    for i, file in enumerate(files):
        fullFrompath = os.path.join(frompath, file)
        fullTopath = os.path.join(topath, file)
        command = "apktool d " + fullFrompath + " -o " + fullTopath
        subprocess.call(command, shell=True)
        print("已反汇编", i+1, "个应用")
        print("百分比为：",(i + 1) * 100 / total, "%")

#反汇编正常软件样本
kind_root = "./bit/normalApk"
disassemble(kind_root, "./smalis/kind", 600)

#反汇编恶意软件样本
virus_root = "./bit/VirusAndroid"
disassemble(virus_root,"./smalis/malware", 600)

#反汇编测试软件样本
test_root = "./bit/testAndroid"
disassemble(test_root,"./smalis/test", 600)

